import { join } from 'path';
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    vue(),
  ],
  resolve: {
    alias: {
      "@": join(__dirname, "src"),
    },
  },

  server: {
    host: true,
    port: 1798,
    proxy: {
      "/api/v1": {
        target: "http://127.0.0.1:8000",
      },
    },
  },
  // 引入全局scss变量
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/style/variables.scss";`,
      },
    },
  },
  publicDir: "/public",
  build:{
    rollupOptions:{
      external:[
        "element-plus"
      ]
    }
  }
});
